import junit.framework.TestCase;
import org.junit.Test;
public class StringBufferDemoTest extends TestCase {
    StringBuffer str1 = new StringBuffer("StringBuffer");
    StringBuffer str2 = new StringBuffer("StringBufferStringBuffer");
    StringBuffer str3 = new StringBuffer("StringBufferStringBufferStringBuffer");
    @Test
    public void testcharAt() throws Exception{
        assertEquals('S',str1.charAt(0));
        assertEquals('g',str1.charAt(5));
        assertEquals('r',str1.charAt(11));
    }
    @Test
    public void testcapacity() throws Exception{
        assertEquals(28,str1.capacity());
        assertEquals(40,str2.capacity());
        assertEquals(52,str3.capacity());
    }
    @Test
    public void testlength() throws Exception{
        assertEquals(12,str1.length());
        assertEquals(24,str2.length());
        assertEquals(36,str3.length());
    }
    @Test
    public void testindexOf() throws Exception{
        assertEquals(0,str1.indexOf("Str"));
        assertEquals(5,str2.indexOf("gBu"));
        assertEquals(10,str3.indexOf("er"));
    }
}
